import { request } from '@/framework/utils/request-jdz';

export const roleSearch = (params) => {
  return request(
    {
      url: '/role/',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 获取所有角色列表
export const getRoleTree = () => {
  return request(
    {
      url: '/func/tree',
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 添加角色
export const roleAdd = (params) => {
  return request(
    {
      url: '/role-plus/',
      method: 'post',
      data: params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 删除角色
export const roleDelete = (id) => {
  return request({
    url: `/role/${id}`,
    method: 'delete',
  });
};
// 更新角色信息
export const roleUpdate = (params) => {
  return request(
    {
      url: `/role-plus/${params.id}`,
      method: 'put',
      data: params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};
//清除缓存
export const getCache = () => {
  return request(
    {
      url: '/utils/cache/clear',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 角色禁用
export const roleDisable = (id) => {
  return request(
    {
      url: `/role/disable/${id}`,
      method: 'put',
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 角色启用
export const roleEnable = (id) => {
  return request(
    {
      url: `/role/enable/${id}`,
      method: 'put',
    },
    {
      isGetDataDirectly: false,
    },
  );
};
